package com.example.pageutils;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import java.util.List;

/**
 * 分页
 * @author lyp
 * @date 2022/7/18 14:47
 */
public class MyPageHelper {


    /**
     * 设置分页参数
     * @param pageRequest
     */
    public static void startPage(PageRequest pageRequest){
        PageHelper.startPage(pageRequest.getPageNum(),pageRequest.getPageSize());
    }


    /**
     * 封装pageInfo
     * @param content
     * @return
     */
    public static PageResult getPageResult(List content){
        PageInfo pageInfo = new PageInfo(content);
        PageResult pageResult = new PageResult();
        pageResult.setTotal(pageInfo.getTotal());
        pageResult.setContent(pageInfo.getList());
        pageResult.setPages(pageInfo.getPages());
        pageResult.setPageSize(pageInfo.getPageSize());
        pageResult.setPageNum(pageInfo.getPageNum());

        return pageResult;
    }

}
